package cn.lotusnut.dynamicscheduled.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;

/**
 * @Author JiangMing Zhou
 * @Date 2023/4/23 10:29
 * @Version 1.8
 */
@Component
public class BeanUtil {
    private static ApplicationContext context;
    public static <T> T getBean(Class<T> bean) {
        return context.getBean(bean);
    }
    public static <T> T getBean(String var1, @Nullable Class<T> var2){
        return context.getBean(var1, var2);
    }
    public static ApplicationContext getContext() {
        return context;
    }
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        context = applicationContext;
    }
}
